package com.zz.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zz.entity.DateUtil;
import com.zz.entity.Statistics;
import com.zz.entity.StatisticsSearch;
import com.zz.service.StatisticsService;

@Controller
@RequestMapping("statistics")
public class StatisticsController {
	@Autowired
	StatisticsService staService;
	
	/**
	 * 测试查询
	 */
	@RequestMapping("getAll1")
	@ResponseBody
	public List<Statistics> getAll1(){
		return staService.GetAll1();
	}
	/**
	 * 多条件分页查询
	 */
	@RequestMapping("getAll")
	@ResponseBody
	public Map<String, Object> getAll(StatisticsSearch staSearch,Integer page,Integer limit){
		return staService.GetAll(staSearch, page, limit);
	}
	/**
	 * 查询某个资源室某个时间段的人数总和
	 */
	@RequestMapping("getPeople")
	@ResponseBody
	public Integer getPeopleNums(Integer id,String begin,String end){
		System.out.println(id+""+begin+""+end);
		if(begin==null)begin="2000-01-01";
		if(end==null)end=new DateUtil().getNewDate();
		System.out.println(id+""+begin+""+end); 
		return staService.GetPeppleNumsByDate(id, begin, end);
	}
	/**
	 * 查询所有资源室某时间段人数
	 */
	@RequestMapping("getStatisticsPeople")
	@ResponseBody
	public List<Map<String, Integer>> getStatisticsPeople(String begin,String end){
		return staService.GetStatisticsPeopleNums(begin, end);
	}
	
	@RequestMapping("getStatisticsPeople1")
	@ResponseBody
	public Object getStatisticsPeople1(String begin,String end){
		return staService.getTJReadRoom(begin, end);
	}
	
	
}
